package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v7.widget.RecyclerView;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dindang.propertyfee.R;
import com.dindang.propertyfee.di.component.DaggerOwnerSearchComponent;
import com.dindang.propertyfee.di.module.OwnerSearchModule;
import com.dindang.propertyfee.mvp.contract.OwnerSearchContract;
import com.dindang.propertyfee.mvp.presenter.OwnerSearchPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.longxi.gamer_base.widget.ClearEditText;
import com.longxi.gamer_base.widget.EmptyLayout;
import com.longxi.gamer_base.widget.FlowLayout;

import in.srain.cube.views.ptr2.PtrClassicFrameLayout;

import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/OwnerSearchActivity")
public class OwnerSearchActivity extends BaseActivity<OwnerSearchPresenter> implements OwnerSearchContract.View {

    ClearEditText mEditText;
    FlowLayout mFlowLayout;
    TextView mTvClearSearchRecord;
    TextView mTvCancle;
    Group mGroupHistory;

    FrameLayout mFramelayout;
    PtrClassicFrameLayout mPtrclassicframelayout;
    RecyclerView mRecyclerview;
    EmptyLayout mEmptyLayout;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerOwnerSearchComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .ownerSearchModule(new OwnerSearchModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_owner_search; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mEditText = findViewById(R.id.et_search);
        mFlowLayout = findViewById(R.id.flow);
        mTvClearSearchRecord = findViewById(R.id.tv_clear_search_record);
        mTvCancle = findViewById(R.id.tv_cancle);
        mGroupHistory = findViewById(R.id.group_history);

        mFramelayout = findViewById(R.id.propertyfee_framelayout);
        mPtrclassicframelayout = findViewById(R.id.propertyfee_ptrclassicframelayout);
        mRecyclerview = findViewById(R.id.propertyfee_recyclerview);
        mEmptyLayout = findViewById(R.id.propertyfee_emptyLayout);

        mPresenter.init();
        mTvCancle.setOnClickListener(v -> mPresenter.toCancle());
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public ClearEditText getEditText() {
        return mEditText;
    }

    @Override
    public FlowLayout getFlowLayout() {
        return mFlowLayout;
    }

    @Override
    public TextView getTvClearSearchRecord() {
        return mTvClearSearchRecord;
    }

    @Override
    public Group getGroupHistory() {
        return mGroupHistory;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

    @Override
    public FrameLayout getFramelayout() {
        return mFramelayout;
    }

    @Override
    public PtrClassicFrameLayout getPtrclassicframelayout() {
        return mPtrclassicframelayout;
    }

    @Override
    public RecyclerView getRecyclerview() {
        return mRecyclerview;
    }

    @Override
    public EmptyLayout getEmptyLayout() {
        return mEmptyLayout;
    }
}
